package StudyCode.summary.mycollection;

import java.util.ArrayList;
import java.util.List;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GetsTheInstancesOfClassInIterable {
	public static <E> List<E> getInstances(Iterable iterable, Class<E> c) {
		ArrayList<E> result = new ArrayList<E>();
		for (Object obj : iterable) {
			if (c.isInstance(obj)) {
				result.add(c.cast(obj));
			}
		}
		return result;
	}
}
